<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.Statement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.sql.SQLException" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title></title>
</head>
<body>
	<div><input type="button" name="btnRegMember" value="회원등록" onclick="location.href='insertForm.jsp'" /></div>
	<table width="100%" border="1">
	<tr>
		<th>이름</th>
		<th>아이디</th>
		<th>이메일</th>
	</tr>
	<%
	
	
	Connection conn = null;
	Statement stmt = null;
	ResultSet rs = null;
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
		
		String jdbcDriver ="jdbc:mysql://192.168.0.200:3306/intra?useUnicode=true&characterEncoding=utf-8";
		String dbUser = "root";
		String dbPass = "ice1234";
		
		String query = "select * from MEMBER";
		conn = DriverManager.getConnection(jdbcDriver,dbUser,dbPass);
		//System.out.println("============="+conn.toString());
		stmt = conn.createStatement();
		rs = stmt.executeQuery(query);
		while(rs.next()){
	%>
	<tr>
		<td><a href="viewMember.jsp?memberID=<%=rs.getString("MEMBERID") %>"><%=rs.getString("NAME") %></a></td>
		<td><a href="viewMember.jsp?memberID=<%=rs.getString("MEMBERID") %>"><%=rs.getString("MEMBERID") %></a></td>
		<td><a href="viewMember.jsp?memberID=<%=rs.getString("MEMBERID") %>"><%=rs.getString("EMAIL") %></a></td>
	</tr>
	<%
		}
	}catch(SQLException ex){
		System.out.println("============="+ex.getLocalizedMessage());	
	}catch(ClassNotFoundException ex){	
		System.out.println("============="+ex.getLocalizedMessage());	
	}finally{
		if(rs != null) try{rs.close();}catch(SQLException ex){}
		if(stmt != null) try{stmt.close();}catch(SQLException ex){}
		if(conn != null) try{conn.close();}catch(SQLException ex){}
	}
	%>
	</table>
</body>
</html>